home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
MEDICAL
/
H121A.ZIP
/
FILES6.EXE
/
lha
/
MEASURE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-07-15
|
27KB
|
688 lines
(*$N+,E+,V-*)
unit measure;
interface
uses Crt, Dos, EntFace;
type
String1 = string[1];
String2 = string[2];
String3 = string[3];
String4 = string[4];
Array14B = array[1..14,1..3,1..5,1..4] of real;
const
Coef : Array14B =
(((( 0.461824E+02, 0.401257E+01,-0.255449E+00, 0.789966E-02),
( 0.673630E+02, 0.133410E+01,-0.421583E-01, 0.101581E-02),
( 0.813173E+02, 0.755023E+00, 0.355289E-02,-0.590137E-03),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00)),
(( 0.504849E+02, 0.438155E+01,-0.312088E+00, 0.105514E-01),
( 0.723318E+02, 0.132797E+01,-0.271990E-01, 0.448522E-03),
( 0.876453E+02, 0.814752E+00,-0.701552E-02, 0.609604E-04),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00)),
(( 0.547862E+02, 0.475220E+01,-0.368845E+00, 0.132042E-01),
( 0.773055E+02, 0.132163E+01,-0.123304E-01,-0.113662E-03),
( 0.939720E+02, 0.874997E+00,-0.174451E-01, 0.693745E-03),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00))),
((( 0.457829E+02, 0.367323E+01,-0.237212E+00, 0.779334E-02),
( 0.653091E+02, 0.129719E+01,-0.267922E-01, 0.466010E-03),
( 0.803115E+02, 0.807980E+00,-0.582173E-02,-0.184636E-03),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00)),
(( 0.498644E+02, 0.393746E+01,-0.262999E+00, 0.884779E-02),
( 0.704487E+02, 0.135350E+01,-0.241086E-01, 0.339627E-03),
( 0.864730E+02, 0.859488E+00,-0.882537E-02, 0.322490E-04),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00)),
(( 0.539292E+02, 0.421102E+01,-0.290055E+00, 0.995372E-02),
( 0.755903E+02, 0.140880E+01,-0.213041E-01, 0.210055E-03),
( 0.926378E+02, 0.911461E+00,-0.118516E-01, 0.242960E-03),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00),
( 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00))),
((( 0.249740E+01, 0.462056E+00, 0.481125E-01,-0.458894E-02),
( 0.601058E+01, 0.543800E+00,-0.344885E-01, 0.973626E-03),
( 0.925227E+01, 0.136684E+00, 0.562077E-03,-0.236327E-04),
( 0.000000E+00, 0.000000E+00, 0.000000E-00, 0.000000E-00),
( 0.000000E+00, 0.000000E+00, 0.000000E-00,-0.000000E-00)),
(( 0.326804E+01, 0.108795E+01,-0.677657E-01, 0.226565E-02),
( 0.784554E+01, 0.519450E+00,-0.269840E-01, 0.738014E-03),
( 0.114685E+02, 0.190655E+00,-0.415541E-03,-0.133747E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+00, 0.000000E+00, 0.000000E-00,-0.000000E-00)),
(( 0.420915E+01, 0.145910E+01,-0.124212E+00, 0.546698E-02),
( 0.967299E+01, 0.558989E+00,-0.258067E-01, 0.644479E-03),
( 0.137784E+02, 0.218043E+00,-0.260545E-02, 0.106811E-03),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+00, 0.000000E+00, 0.000000E-00,-0.000000E-00))),
((( 0.230235E+01, 0.545715E+00, 0.131161E-01,-0.221402E-02),
( 0.557059E+01, 0.463994E+00,-0.267363E-01, 0.773006E-03),
( 0.862425E+01, 0.156261E+00, 0.109190E-02,-0.898380E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.322751E+01, 0.768817E+00,-0.124130E-01,-0.857452E-03),
( 0.720834E+01, 0.527256E+00,-0.278471E-01, 0.752199E-03),
( 0.108252E+02, 0.183875E+00,-0.767982E-03, 0.714597E-05),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.391945E+01, 0.115426E+01,-0.635733E-01, 0.176581E-02),
( 0.893781E+01, 0.582092E+00,-0.317886E-01, 0.930288E-03),
( 0.129529E+02, 0.221049E+00, 0.170173E-02,-0.906913E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))),
((( 0.250836E+01, 0.681768E-01, 0.126871E-01,-0.259413E-03),
( 0.763160E+01, 0.240094E+00,-0.521241E-02, 0.150006E-03),
( 0.111393E+02, 0.198252E+00, 0.288790E-02,-0.207356E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.314986E+01, 0.148592E+00, 0.947678E-02,-0.205609E-03),
( 0.907905E+01, 0.258223E+00,-0.471024E-02, 0.132953E-03),
( 0.129763E+02, 0.217885E+00, 0.246924E-02, 0.104389E-03),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.409354E+01, 0.188963E+00, 0.873912E-02,-0.193446E-03),
( 0.107090E+02, 0.283963E+00,-0.460866E-02, 0.113211E-03),
( 0.149874E+02, 0.228093E+00, 0.150476E-02, 0.133490E-03),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))),
((( 0.260988E+01, 0.630037E-01, 0.115431E-01,-0.231559E-03),
( 0.734790E+01, 0.226503E+00,-0.443447E-02, 0.137357E-03),
( 0.107892E+02, 0.200373E+00, 0.298280E-02, 0.891100E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.329545E+01, 0.103651E+00, 0.119637E-01,-0.255793E-03),
( 0.889598E+01, 0.248036E+00,-0.568606E-02, 0.181276E-03),
( 0.125756E+02, 0.219539E+00, 0.410286E-02,-0.204386E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.393902E+01, 0.201926E+00, 0.746380E-02,-0.178154E-03),
( 0.103641E+02, 0.262530E+00,-0.482882E-02, 0.154783E-03),
( 0.144278E+02, 0.239142E+00, 0.352948E-02, 0.139341E-03),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))),
((( 0.322108E+02, 0.258812E+01,-0.249611E+00, 0.111355E-01),
( 0.411588E+02, 0.795414E+00,-0.491726E-01, 0.131269E-02),
( 0.458912E+02, 0.182354E+00,-0.191581E-02,-0.463902E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.348510E+02, 0.253355E+01,-0.235109E+00, 0.101480E-01),
( 0.437804E+02, 0.808235E+00,-0.524443E-01, 0.140200E-02),
( 0.483499E+02, 0.155234E+00,-0.197246E-02,-0.549570E-05),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.373458E+02, 0.284554E+01,-0.312001E+00, 0.150148E-01),
( 0.464302E+02, 0.723126E+00,-0.417343E-01, 0.106348E-02),
( 0.509357E+02, 0.180925E+00,-0.344910E-02, 0.218012E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))),
((( 0.320688E+02, 0.210232E+01,-0.165974E+00, 0.640051E-02),
( 0.400902E+02, 0.801885E+00,-0.507646E-01, 0.138010E-02),
( 0.447875E+02, 0.179737E+00,-0.108106E-02,-0.652464E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.342817E+02, 0.231444E+01,-0.217205E+00, 0.966608E-02),
( 0.424368E+02, 0.751914E+00,-0.432157E-01, 0.108307E-02),
( 0.471083E+02, 0.182624E+00,-0.422515E-02, 0.400879E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.359806E+02, 0.283176E+01,-0.317336E+00, 0.154859E-01),
( 0.448920E+02, 0.696214E+00,-0.385893E-01, 0.942081E-03),
( 0.493177E+02, 0.177050E+00,-0.467440E-02, 0.903841E-04),
( 0.000000E+00, 0.000000E+00,-0.000000E-00, 0.000000E-00),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))),
((( 0.796017E+02, 0.725005E+00,-0.394565E-02, 0.149043E-04),
( 0.133056E+03, 0.406485E+00, 0.115162E-02, 0.272229E-04),
( 0.147022E+03, 0.549084E+00, 0.360168E-02,-0.162614E-03),
( 0.163870E+03, 0.176161E+00,-0.139606E-01, 0.257402E-03),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.855931E+02, 0.837795E+00,-0.533792E-02, 0.233837E-04),
( 0.146374E+03, 0.532432E+00, 0.265930E-02,-0.599481E-04),
( 0.163122E+03, 0.530131E+00,-0.273603E-02,-0.522667E-04),
( 0.176222E+03, 0.129924E+00,-0.838083E-02, 0.143430E-03),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.915767E+02, 0.950895E+00,-0.673349E-02, 0.318732E-04),
( 0.159692E+03, 0.658332E+00, 0.416714E-02,-0.147054E-03),
( 0.179222E+03, 0.511316E+00,-0.906767E-02, 0.577848E-04),
( 0.188574E+03, 0.831110E-01,-0.282691E-02, 0.382714E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))),
((( 0.784609E+02, 0.769969E+00,-0.579066E-02, 0.299200E-04),
( 0.100071E+03, 0.469370E+00,-0.255930E-02, 0.298134E-04),
( 0.131726E+03, 0.564490E+00, 0.388040E-02,-0.211730E-03),
( 0.144582E+03, 0.384879E+00,-0.113642E-01, 0.132304E-03),
( 0.149882E+03, 0.810578E-01, 0.292469E-02,-0.738429E-04)),
(( 0.844872E+02, 0.877385E+00,-0.854191E-02, 0.726632E-04),
( 0.105083E+03, 0.561061E+00,-0.200222E-02, 0.171075E-04),
( 0.144783E+03, 0.560961E+00, 0.200094E-02,-0.164240E-03),
( 0.157128E+03, 0.373200E+00,-0.982432E-02, 0.982153E-04),
( 0.162413E+03, 0.477105E-01, 0.782933E-03,-0.217935E-04)),
(( 0.905784E+02, 0.973526E+00,-0.108372E-01, 0.109954E-03),
( 0.112999E+03, 0.620169E+00,-0.941330E-03, 0.461746E-05),
( 0.157837E+03, 0.557600E+00, 0.139156E-03,-0.117406E-03),
( 0.169676E+03, 0.361401E+00,-0.831408E-02, 0.648912E-04),
( 0.174939E+03, 0.150850E-01,-0.130583E-02, 0.268575E-04))),
((( 0.102271E+02, 0.110605E+00, 0.502728E-03,-0.356088E-05),
( 0.194677E+02, 0.127619E+00,-0.266421E-03, 0.234381E-04),
( 0.312284E+02, 0.348780E+00, 0.395244E-02,-0.674519E-04),
( 0.496166E+02, 0.261986E+00,-0.576064E-02, 0.333672E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.123424E+02, 0.202445E+00,-0.116412E-02, 0.118225E-04),
( 0.252964E+02, 0.218676E+00, 0.138954E-02, 0.709375E-05),
( 0.449515E+02, 0.462032E+00, 0.266641E-02,-0.629917E-04),
( 0.663061E+02, 0.282610E+00,-0.640439E-02, 0.619515E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.154874E+02, 0.219986E+00,-0.841307E-03, 0.189821E-04),
( 0.340501E+02, 0.394048E+00, 0.325883E-02,-0.164077E-04),
( 0.658807E+02, 0.607904E+00, 0.305441E-03,-0.377818E-04),
( 0.915854E+02, 0.376078E+00,-0.513514E-02,-0.177567E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))),
((( 0.958878E+01, 0.162168E+00,-0.158785E-02, 0.141728E-04),
( 0.166639E+02, 0.124691E+00, 0.963245E-03, 0.307446E-05),
( 0.282771E+02, 0.273485E+00, 0.151665E-02,-0.370240E-04),
( 0.408042E+02, 0.163173E+00,-0.381481E-02, 0.315956E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.117963E+02, 0.219662E+00,-0.262788E-02, 0.292835E-04),
( 0.218409E+02, 0.220578E+00, 0.264314E-02,-0.141618E-04),
( 0.415319E+02, 0.384808E+00, 0.940228E-04,-0.391686E-04),
( 0.558876E+02, 0.123101E+00,-0.554625E-02, 0.702252E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.144385E+02, 0.322835E+00,-0.438366E-02, 0.540144E-04),
( 0.296945E+02, 0.380152E+00, 0.533894E-02,-0.449181E-04),
( 0.620215E+02, 0.535709E+00,-0.274632E-02,-0.206170E-04),
( 0.791280E+02, 0.129558E+00,-0.571516E-02, 0.648512E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))),
((( 0.288221E+01, 0.311757E+00,-0.339993E-02, 0.332712E-04),
( 0.907104E+01, 0.204144E+00,-0.904587E-03, 0.465496E-04),
( 0.171038E+02, 0.311893E+00, 0.398312E-02,-0.276662E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.431260E+01, 0.371447E+00,-0.633119E-02, 0.877037E-04),
( 0.110122E+02, 0.219333E+00, 0.246595E-03, 0.313171E-04),
( 0.203336E+02, 0.351685E+00, 0.353489E-02, 0.104383E-03),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.658687E+01, 0.352637E+00,-0.345830E-02, 0.293354E-04),
( 0.136997E+02, 0.234726E+00,-0.125814E-02, 0.889698E-04),
( 0.241885E+02, 0.473620E+00, 0.808368E-02, 0.103298E-03),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))),
((( 0.303896E+01, 0.276098E+00,-0.226928E-02, 0.201277E-04),
( 0.982301E+01, 0.194286E+00,-0.457785E-03, 0.537775E-04),
( 0.147037E+02, 0.258573E+00, 0.325286E-02, 0.168530E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.430208E+01, 0.364667E+00,-0.629446E-02, 0.835936E-04),
( 0.118341E+02, 0.212702E+00, 0.122896E-02, 0.201561E-04),
( 0.176216E+02, 0.301222E+00, 0.261973E-02, 0.121334E-03),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04)),
(( 0.658206E+01, 0.363970E+00,-0.609859E-02, 0.885250E-04),
( 0.144026E+02, 0.237072E+00, 0.186866E-02, 0.269321E-04),
( 0.211715E+02, 0.365772E+00, 0.372698E-02, 0.332188E-03),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04),
( 0.000000E+01, 0.000000E+00, 0.000000E-02,-0.000000E-04))));
Fudge = 1E-9;
var
Knot : array[1..14,1..5] of real;
Procedure JCS2ZS (Age : real; ISex : Byte;
Ht, Wt : Real;
var HAC, WHC, WAC, HAZ, WHZ, WAZ, HAPM, WHPM, WAPM : Real;
var Flag : Byte);
Function MyDoScores (Header : FieldPtr;
Current : FieldPtr;
Data : Integer) : Integer;
implementation
{----------------------------------------------------------------------------}
{ }
{----------------------------------------------------------------------------}
procedure InitKnot;
begin
Knot[1,1] := 0.0; Knot[2,1] := 0.0; Knot[3,1] := 0.0;
Knot[4,1] := 0.0; Knot[5,1] := 49.0; Knot[6,1] := 49.0;
Knot[7,1] := 0.0; Knot[8,1] := 0.0; Knot[9,1] := 24.0;
Knot[10,1] := 24.0; Knot[11,1] := 24.0; Knot[12,1] := 24.0;
Knot[13,1] := 55.0; Knot[14,1] := 55.0;
Knot[1,2] := 9.0; Knot[2,2] := 9.0; Knot[3,2] := 6.0;
Knot[4,2] := 6.0; Knot[5,2] := 72.0; Knot[6,2] := 72.0;
Knot[7,2] := 6.0; Knot[8,2] := 6.0; Knot[9,2] := 138.0;
Knot[10,2] := 54.0; Knot[11,2] := 96.0; Knot[12,2] := 84.0;
Knot[13,2] := 80.0; Knot[14,2] := 85.0;
Knot[1,3] := 24.0; Knot[2,3] := 24.0; Knot[3,3] := 18.0;
Knot[4,3] := 18.0; Knot[5,3] := 90.0; Knot[6,3] := 90.0;
Knot[7,3] := 18.0; Knot[8,3] := 18.0; Knot[9,3] := 168.0;
Knot[10,3] := 132.0; Knot[11,3] := 156.0; Knot[12,3] := 144.0;
Knot[13,3] := 115.0; Knot[14,3] := 108.0;
Knot[1,4] := 0.0; Knot[2,4] := 0.0; Knot[3,4] := 0.0;
Knot[4,4] := 0.0; Knot[5,4] := 0.0; Knot[6,4] := 0.0;
Knot[7,4] := 0.0; Knot[8,4] := 0.0; Knot[9,4] := 204.0;
Knot[10,4] := 156.0; Knot[11,4] := 204.0; Knot[12,4] := 192.0;
Knot[13,4] := 0.0; Knot[14,4] := 0.0;
Knot[1,5] := 0.0; Knot[2,5] := 0.0; Knot[3,5] := 0.0;
Knot[4,5] := 0.0; Knot[5,5] := 0.0; Knot[6,5] := 0.0;
Knot[7,5] := 0.0; Knot[8,5] := 0.0; Knot[9,5] := 0.0;
Knot[10,5] := 192.0; Knot[11,5] := 0.0; Knot[12,5] := 0.0;
Knot[13,5] := 0.0; Knot[14,5] := 0.0;
end;
{----------------------------------------------------------------------------}
{ }
{----------------------------------------------------------------------------}
procedure Eval(X : real; I,J : integer; var V : real; LL,UL : real);
label L10, L20, L30, L40, L50;
const
KD : array[1..14] of integer = (3,3,3,3,3,3,3,3,4,5,4,4,3,3);
var
K : byte;
A : real;
begin
if J = 1 then Knot[10,2] := 60.0;
if J <> 1 then Knot[10,2] := 54.0;
if ((X < LL) or (X > UL)) and (LL <> UL) then GOTO L50;
K := KD[I];
L10:
A := X - Knot[I,K];
if A < 0 then GOTO L20
else GOTO L40;
L20:
K := K - 1;
if K > 0 then GOTO L10
else GOTO L30;
L30:
K := 1;
L40:
V := Coef[I,J,K,1] + A * (Coef[I,J,K,2] + A * (Coef[I,J,K,3] +
A * Coef[I,J,K,4]));
Exit;
L50:
V := 999.9;
end;
{----------------------------------------------------------------------------}
{ }
{----------------------------------------------------------------------------}
procedure ZScr (I : integer; X, Ms : real; var Zsc, LL, UL : real);
label L20, L30, L40;
var
J : byte;
V,
XX,
AZsc : real;
SD : array[1..2] of real;
Y : array[1..3] of real;
begin
if ((X < LL) or (X > UL)) and (LL <> UL) then GOTO L40;
for J := 1 to 3 do
begin
Eval(X,I,J,V,LL,UL);
Y[J] := V
end;
SD[1] := Abs((Y[2] - Y[1]) / 1.8807936);
SD[2] := Abs((Y[2] - Y[3]) / 1.8807936);
if (LL <> UL) then GOTO L20;
ZSc := Y[2];
LL := SD[1];
UL := SD[2];
Exit;
L20:
if (Ms >= Y[2]) then GOTO L30;
ZSc := (Ms - Y[2]) / SD[1];
if ZSc >= -9.98 then Exit;
ZSc := -9.98;
Exit;
L30:
ZSc := (Ms - Y[2]) / SD[2];
if ZSc <= 9.98 then Exit;
ZSc := 9.98;
Exit;
L40:
ZSc := 9.99
end;
{--------------------------------------------------------------------}
{ The following function raises X to the power Y }
{--------------------------------------------------------------------}
function XToPowerY (X, Y : real) : real;
begin
XToPowerY := Exp(Y * Ln(X))
end;
{--------------------------------------------------------------------}
{ }
{--------------------------------------------------------------------}
function ZPct (Z : real) : real;
const
B : array[1..5] of real = (0.31938153, -0.356563782, 1.781477937,
-1.821255978, 1.330274429);
var
TempZPct,
DZp,
DZ,
R,
T,
Fx : real;
I,
Neg : integer;
begin
DZp := 0.0;
R := 0.2316419;
if Z > 9.985 then ZPct := 99.9
else
begin
Neg := 0;
DZp := 0.0;
if Z < 0 then Neg := 1;
DZ := Abs(Z);
T := 1.0 / (1.0 + DZ * R);
for I := 1 to 5 do
DZp := B[I] * XToPowerY(T, I) + DZp;
Fx := 1.0 / Sqrt(2 * Pi) * Exp(-0.5 * Sqr(DZ));
DZp := DZp * Fx;
TempZPct := DZp * 100.0;
if Neg <> 1 then TempZPct := 100.0 - TempZPct;
if (TempZPct > 99.8) then TempZPct := 99.8;
ZPct := TempZPct
end
end;
{----------------------------------------------------------------------------}
{ }
{----------------------------------------------------------------------------}
procedure JCS2ZS (Age : real; ISex : Byte;
Ht, Wt : Real;
var HAC, WHC, WAC, HAZ, WHZ, WAZ, HAPM, WHPM, WAPM : Real;
var Flag : Byte);
label L10, L20, L40, L50, L60, L70, L80, L90, L100, L110, L120, L130, L140,
L150, L160, L170;
const
ULmt : array[1..16] of real = (36.0, 36.0, 36.0, 36.0,
103.0, 101.0, 36.0, 36.0,
215.99, 215.99, 215.99, 215.99,
145.0, 137.0, 138.0, 120.0);
LLmt : array[1..16] of real = (0.0, 0.0, 0.0, 0.0,
49.0, 49.0, 0.0, 0.0,
24.0, 24.0, 24.0, 24.0,
55.0, 55.0, 24.0, 24.0);
var
ErrCode,
I : integer;
X,
MS,
PMed,
Cntl,
UL,
LL,
V,
WZ,
ZSc : real;
Function StrToByte (S : String) : Integer;
Var
I, J : Integer;
Begin
Val (S, I, J);
If J <> 0
Then
I := 0;
StrToByte := I
End (*StrToByte*);
Function StrToReal (S : String) : Real;
Var
I : Integer;
R : Real;
Begin
Val (S, R, I);
If I <> 0
Then
R := 0;
StrToReal := R
End (*StrToReal*);
Function Form (S : String; Num : Real) : String;
Begin
Str (Num: Length (S): 0, S);
Form := S
End (*Form*);
begin
{
Val(AgeMos + Age100s, Age, ErrCode); (*******************************)
Age := Age / 100; (* Note : conversions could *)
Val(StSex, ISex, ErrCode); (* be done this way and avoid *)
Val(StHt, Ht, ErrCode); (* using the Math unit. *)
Ht := Ht / 10; (* This could pay off if *)
Val(StWt, Wt,ErrCode); (* all other pieces of the *)
Wt := Wt / 10; (* puzzle can avoid Math also *)
} (*******************************)
if (ISex <> 1) and (ISex <> 2) then GOTO L150;
If (Age >= 0.0) and (Age <= 215.99) then GOTO L40;
I := ISex + 4;
LL := LLmt[I];
UL := ULmt[I];
if (Ht >= 85.0) then GOTO L10;
if (Ht < LL) then GOTO L150;
If (Wt > 999.0) then GOTO L150;
ZScr(I,Ht,Wt,WHZ,LL,UL);
Eval(Ht,I,2,WZ,LL,UL);
GOTO L20;
L10:
I := I + 8;
LL := LLmt[I];
UL := ULmt[I];
if (Ht > UL) then GOTO L150;
if (Wt > 999.0) then GOTO L150;
ZScr(I,Ht,Wt,WHZ,LL,UL);
Eval(Ht,I,2,WZ,LL,UL);
L20:
WHPM := Wt / Wz * 100.0;
WHC := ZPct(WHZ);
GOTO L160;
L40:
if (Age < 24.0) then GOTO L50;
I := ISex + 8;
GOTO L60;
L50:
I := ISex;
L60:
MS := Ht;
X := Age;
L70:
UL := ULmt[I];
LL := LLmt[I];
if (X < LL) or (X > UL) then GOTO L80;
if (MS > 999.0) or (MS <= 0.01) then GOTO L80;
Eval(X,I,2,V,LL,UL);
ZScr(I,X,MS,ZSc,LL,UL);
PMed := (MS / V) * 100.0;
GOTO L90;
L80:
PMed := 999.9;
ZSc := 9.99;
L90:
case I of
1,2, 9,10 : GOTO L100;
3,4,11,12 : GOTO L110;
5,6,13,14 : GOTO L120;
7,8,15,16 : GOTO L170
end;
L100:
HAPM := PMed;
HAZ := ZSc;
HAC := ZPct(ZSc);
Ms := Wt;
GOTO L140;
L110:
WAPM := PMed;
WAZ := ZSc;
WAC := ZPct(Zsc);
X := Ht;
GOTO L140;
L120:
X := Age;
UL := ULmt[I + 2];
LL := LLmt[I + 2];
if (X < LL) or (X > UL) then GOTO L130;
if (Wt > 999.0) then GOTO L130;
WHPM := PMed;
WHZ := ZSc;
WHC := ZPct(ZSc);
GOTO L170;
L130:
WHC := 99.9;
WHPM := 999.9;
WHZ := 9.99;
GOTO L170;
L140:
I := I + 2;
GOTO L70;
L150:
WHC := 99.9;
WHPM := 999.9;
WHZ := 9.99;
L160:
HAC := 99.9;
HAPM := 999.9;
HAZ := 9.99;
WAC := 99.9;
WAPM := 999.9;
WAZ := 9.99;
L170:
(**************************************************************************)
(* The following variable Flag is an addition requested by Kevin Sullivan *)
(* and was added on 1/10/90 by Ray Smith. I think we probably need to *)
(* check on the branching that could lead to execution of these *)
(* statements when preceeding logic leads to the 999 type values. *)
(**************************************************************************)
Flag := 0;
if (HAZ < -6) or (HAZ > 6) then Flag :=1;
if (WHZ < -4) or (WHZ > 6) then Inc(Flag,2);
if (WAZ < -6) or (WAZ > 6) then Inc(Flag,4);
if ((HAZ > 3.09) and (WHZ < -3.09)) or
((HAZ < -3.09) and (WHZ > 3.09)) then
if (Flag >= 0) and (Flag < 4) then
Flag := 3
else
Flag := 7;
end;
(*$F+*)
Function MyDoScores (Header : FieldPtr;
Current : FieldPtr;
Data : Integer) : Integer;
Var
AgePtr, SexPtr, WtPtr, HtPtr : FieldPtr;
ISex, Flag : Byte;
HAC, WHC, WAC, HAZ, WHZ, WAZ, HAPM, WHPM, WAPM : Real;
Ch : Char;
S : String[80];
Procedure FieldNotFound;
Begin
GotoXY (1, 23);
Write ('Something wrong with interprogram communication.');
MyDoScores := 1;
Ch := ReadKey
End (*Else*);
Begin {MyDoScores}
MyDoScores := 0;
SwapVectors;
AgePtr := FindField (Header, 'AGE');
SexPtr := FindField (Header, 'SEX');
WtPtr := FindField (Header, 'WEIGHT');
HtPtr := FindField (Header, 'HEIGHT');
If Ageptr = nil then
begin
GotoXY (1,22);
write ('AGEPTR is nil');
end;
TextAttr := 31;
If (AgePtr <> NIL) And (SexPtr <> NIL) And
(WtPtr <> NIL) And (HtPtr <> NIL)
Then
Begin
{Get the contents of four fields in the questionnaire and send
to the JCS2ZS procedure to perform calculations. Could have
used GetString and GetNumber here to make the code clearer, but
this illustrates how to access the FieldList records
in ENTER directly.}
If SexPtr ^.FieldEntry [1] in ['F', 'f', '2']
Then
ISex := 2
Else If SexPtr^.FieldEntry[1] in ['M', 'm', '1']
Then
ISex := 1;
{Send out the 4 values and get 10 back}
JCS2ZS (AgePtr ^.FieldReal, ISex,
HtPtr ^.FieldReal, WtPtr ^.FieldReal,
HAC, WHC, WAC, HAZ, WHZ, WAZ, HAPM, WHPM, WAPM, Flag);
{ Write Height for Age information to fields in questionnaire}
PutNumber (Header,'HAP',HAC);
PutNumber (Header,'HAZ',HAZ);
PutNumber (header,'HAM',HAPM);
{ Write Weight for Age information }
PutNumber (Header,'WAP',WAC);
PutNumber (Header,'WAZ',WAZ);
PutNumber (Header,'WAM',WAPM);
{ Write Weight for Height information }
PutNumber (Header,'WHP',WHC);
PutNumber (Header,'WHZ',WHZ);
PutNumber (Header,'WHM',WHPM);
{ Write Flag information }
PutNumber (Header,'FLAG',Flag);
End (*If*)
Else FieldNotFound;
SwapVectors
End (*MyDoScores*);
(*$F-*)
(***************)
(* Main Body *)
(***************)
begin
InitKnot;
end.